<?php
class ZsxmModel extends Action{
	//test
	//
	//############test
	public function getlastzsxmo(){
		$info=collectinfo(__METHOD__,'',array());
		
		$zsxm=M('zsxm');
		$zsxmo=$zsxm->order('zsxmid DESC')->find();

		return createarrok('ok',$zsxmo,'',$info);
	}

	//############test
	public function getzsxmobyzsxmid($zsxmid){
		$info=collectinfo(__METHOD__,'$zsxmid',array($zsxmid));
		
		$zsxm=M('zsxm');
		$zsxmo=$zsxm->where('zsxmid='.$zsxmid)->find();

		return createarrok('ok',$zsxmo,'',$info);
	}
	
	//############test
	public function getzsxmlsfoujiesuan(){
		$info=collectinfo(__METHOD__,'',array());
		
		$zsxm=M('zsxm');
		$zsxmls=$zsxm->where('zsxmsfjs=0')->select();

		return createarrok('ok',$zsxmls,'',$info);
	}

	############test
	public function updateyhqnum($zsxmid,$yhqnum){
		$info=collectinfo(__METHOD__,'$zsxmid,$yhqnum',array($zsxmid,$yhqnum));
		
		$zsxm=M('zsxm');
		$dt=array('zsxmyhqnum'=>$yhqnum);
		$zsxmls=$zsxm->where('zsxmid='.$zsxmid)->setField($dt);

		return createarrok('ok',$data,'',$info);
	}

	############test
	public function getmonthbonus($str){
		$info=collectinfo(__METHOD__,'$str',array($str));
		
		$zsxm=M('zsxm');
		
		$zsxmls=$zsxm->where("zsxmtm LIKE '%".$str."%'")->select();
		$bonus=0;
		foreach($zsxmls as $zsxmv){
			$jsje=$zsxmv['zsxmjsje'];
			if(strstr($jsje,'=')){$jsje=split('=', $jsje)[1];}
			$bonus=$bonus+$jsje;
		}

		return createarrok('ok',$bonus,'',$info);
	}
} 
?>